<template>
  <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
    <el-tab-pane label="车道管理" name="first">

      <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                 label-width="68px">


          <el-form-item label="物业名称" prop="pmid">
            <el-select v-model="queryParams.pmid" placeholder="请选择物业名称" @change="clearCarshomeList"
                       clearable>
              <el-option
                v-for="item in this.propertyList"
                :key="item.pmid"
                :label="item.propertyName"
                :value="item.pmid">
              </el-option>
            </el-select>
          </el-form-item>


          <el-form-item label="车场名称" prop="chid">
            <el-select v-model="queryParams.chid" placeholder="请选择车场名称" @visible-change="getListCars" clearable>
              <el-option
                v-for="item in this.carshomeList"
                :key="item.chid"
                :label="item.chname"
                :value="item.chid">
              </el-option>
            </el-select>
          </el-form-item>


          <el-form-item label="车道名称" prop="lanename">
            <el-input
              v-model="queryParams.lanename"
              placeholder="请输入车道名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>


          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">

          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['sys-cars-home:lane:add']"
            >新增
            </el-button>


          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['sys-cars-home:lane:edit']"
            >修改
            </el-button>
          </el-col>


          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['sys-cars-home:lane:remove']"
            >删除
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['sys-cars-home:lane:export']"
            >导出
            </el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="laneList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center"/>
          <el-table-column label="车道id" align="center" prop="chlid"/>
          <el-table-column label="物业名称" align="center" prop="propertyManagement.propertyName"/>
          <el-table-column label="所属车场" align="center" prop="carsHome.chname"/>
          <el-table-column label="所属岗亭" align="center" prop="carsHomeBooth.boothname"/>
          <el-table-column label="车道名称" align="center" prop="lanename"/>
          <el-table-column label="车道编号" align="center" prop="lanecode"/>
          <el-table-column label="车道类型" align="center" prop="lanetype" :formatter="showType"/>

          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleLook(scope.row)"
                v-hasPermi="['sys-cars-home:lane:edit']"
              >查看
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['sys-cars-home:lane:edit']"
              >修改
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['sys-cars-home:lane:remove']"
              >删除
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleEdit(scope.row)"
                v-hasPermi="['sys-cars-home:lane:edit']"
              >配置
              </el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />

      </div>


    </el-tab-pane>
    <el-tab-pane label="设备配置" name="second">

      <div>
        <el-form>
          <el-form-item label="车场名称" prop="chid">
            <el-select v-model="editList.chid" placeholder="请选择车场名称" @change="getListLanes" clearable>
              <el-option
                v-for="item in this.carshomeList2"
                :key="item.chid"
                :label="item.chname"
                :value="item.chid">
              </el-option>
            </el-select>

            <el-button plain @click="shuaxin" style="margin-left: 20px">刷新</el-button>
            <el-button plain @click="handleAdd">新增车道</el-button>
          </el-form-item>
        </el-form>

      </div>

      <div class="box-contrain">
        <div style="width: 20%;border: rgba(90,94,102,0.24) solid 1px;padding: 15px">
          <div
            style="font-size: x-large;font-weight: bold;padding: 15px;text-align: left;border-bottom: rgba(90,94,102,0.24) solid 1px">
            车道列表
          </div>
          <div>
            <el-tree :data="data" :props="defaultProps" default-expand-all @node-click="handleNodeClick"></el-tree>
          </div>


        </div>
        <div style="width: 70%;border: rgba(90,94,102,0.24) solid 1px;padding: 15px" class="edit">


          <p style="font-size: 25px;line-height: 1.5;" v-show="infobooth">
            1.请点击岗亭下的车道,为设备配置选项<br>
            2.确保岗亭下有车道，若没有车道，请在车道管理中创建对应的车道<br>
            3.确保停车场下有岗亭，若没有岗亭，请在岗亭管理中创建对应的岗亭<br>
            4.车道列表是二级树形结构图，一级表示岗亭，二级表示车道</p>


          <el-tabs v-show="infolane" v-model="lanename">
            <!--            通道信息------------------------------------------------------------------------------------------------->
            <el-tab-pane label="通道信息" name="one">

              <div>
                <el-form ref="elForm" :model="laneform" size="medium" label-width="100px">
                  <el-form-item label="所属车场" prop="chname">
                    <el-input v-model="laneform.chname" :maxlength="11" show-word-limit :disabled='true' clearable
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label="所属岗亭" prop="boothname">
                    <el-input v-model="laneform.boothname" :disabled='true' clearable
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label="车道ID" prop="chlid">
                    <el-input v-model="laneform.chlid" :disabled='true' clearable :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label="车道名称" prop="lanename">
                    <el-input v-model="laneform.lanename" :disabled='true' clearable
                              :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label="车道类型" prop="lanetype">
                    <el-select v-model="laneform.lanetype" :disabled='true' clearable :style="{width: '100%'}">
                      <el-option v-for="(item, index) in lanetypeOptions" :key="index" :label="item.label"
                                 :value="item.value" :disabled="item.disabled"></el-option>
                    </el-select>
                  </el-form-item>
                </el-form>
              </div>
              <!--              车牌识别----------------------------------------------------------------------------------------------->

            </el-tab-pane>
            <el-tab-pane label="车牌识别" name="two">

              <div>
                <el-row :gutter="15">
                  <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
                    <el-col :span="12">
                      <el-form-item label="设备名称" prop="entifyname">
                        <el-input v-model="formData.entifyname" placeholder="请输入设备名称" :maxlength="11"
                                  show-word-limit
                                  clearable prefix-icon='el-icon-mobile' :style="{width: '100%'}"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="设备编号" prop="eqnumber">
                        <el-input v-model="formData.eqnumber" placeholder="请输入设备编号" clearable
                                  :style="{width: '100%'}">
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="关联码" prop="correlation">
                        <el-input v-model="formData.correlation" placeholder="请输入关联码" clearable
                                  :style="{width: '50%'}"
                        >
                        </el-input><el-button @click="getCorrelation" >随机生成</el-button>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="主副相机" prop="mors">
                        <el-select v-model="formData.mors" placeholder="请选择主副相机" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in morsOptions" :key="index" :label="item.label"
                                     :value="item.value" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="异常开闸" prop="oorg">
                        <el-select v-model="formData.oorg" placeholder="请选择异常开闸" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in oorgOptions" :key="index" :label="item.label"
                                     :value="item.value" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否启用" prop="status">
                        <el-select v-model="formData.status" placeholder="请选择是否启用" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in statusOptions" :key="index" :label="item.label"
                                     :value="item.value" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="设备日志" prop="log">
                        <el-select v-model="formData.log" placeholder="请选择是否开启设备日志" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in logOptions" :key="index" :label="item.label"
                                     :value="item.value" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="所在场地" prop="venue">
                        <el-select v-model="formData.venue" placeholder="请选择所在场地" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in venueOptions" :key="index" :label="item.label"
                                     :value="item.value" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="设备IP" prop="ipaddr">
                        <el-input v-model="formData.ipaddr" placeholder="请输入设备IP" clearable
                                  :style="{width: '100%'}">
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">

                      <el-form-item label="相机品牌" prop="cameraid">
                        <el-select v-model="formData.cameraid" placeholder="请选择相机品牌" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in cameraidOptions" :key="index" :label="item.cameraname"
                                     :value="item.cameraid" :disabled="item.disabled"></el-option>
                        </el-select>


                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="板卡名称" prop="boardsid">
                        <el-select v-model="formData.boardsid" placeholder="请选择板卡名称" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in boardsidOptions" :key="index" :label="item.boardsname"
                                     :value="item.boardsid" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="相机协议" prop="agreement">
                        <el-select v-model="formData.agreement" placeholder="请选择相机协议" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in agreementOptions" :key="index" :label="item.label"
                                     :value="item.value" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="视频接入" prop="video">
                        <el-radio-group v-model="formData.video" size="medium">
                          <el-radio v-for="(item, index) in videoOptions" :key="index" :label="item.value"
                                    :disabled="item.disabled">{{ item.label }}
                          </el-radio>
                        </el-radio-group>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="屏显类型" prop="screentype">
                        <el-select v-model="formData.screentype" placeholder="请选择屏显类型" clearable
                                   :style="{width: '100%'}">
                          <el-option v-for="(item, index) in screentypeOptions" :key="index" :label="item.label"
                                     :value="item.value" :disabled="item.disabled"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="播报音量" prop="volume" required>
                        <el-slider :max='10' :step='1' v-model="formData.volume"></el-slider>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="备注" prop="remark">
                        <el-input v-model="formData.remark" type="textarea" placeholder="请输入备注"
                                  :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
                      </el-form-item>
                    </el-col>

                    <el-col :span="24">
                      <el-form-item size="large">
                        <el-button type="primary" @click="toentify">{{ message }}</el-button>
                        <el-button @click="resetFormentify">重置</el-button>
                      </el-form-item>
                    </el-col>

                  </el-form>
                </el-row>
              </div>


            </el-tab-pane>
            <el-tab-pane label="通行车辆" name="third">


              <div style="border: #1c84c6; solid: 1px; width: 20px;height: 20px ">

              </div>

            </el-tab-pane>


            <el-tab-pane label="ETC天线" name="four">

              <div>
                <el-row :gutter="15">
                  <el-form ref="elFormETC" :model="formData" :rules="rulesETC" size="medium" label-width="100px">
                    <el-col :span="22">
                      <el-form-item label-width="118px" label="ETC车场编码" prop="appip">
                        <el-input v-model="formData.appip" placeholder="APPID" clearable :style="{width: '100%'}">
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="22">
                      <el-form-item label-width="118px" label="ETC车道编号" prop="chlid">
                        <el-input v-model="entifyform.chlid" placeholder="请输入ETC车道编号" readonly clearable
                                  :style="{width: '100%'}"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item size="large">
                        <el-button type="primary" @click="toentify">提交</el-button>
                        <el-button @click="resetFormETC">重置</el-button>
                      </el-form-item>
                    </el-col>
                  </el-form>
                </el-row>
              </div>


            </el-tab-pane>
<!--            <el-tab-pane label="智能终端" disabled></el-tab-pane>-->
<!--            <el-tab-pane label="剩余车位显示屏" disabled></el-tab-pane>-->
            <el-tab-pane label="临时广告设置" name="five">
              <p style="font-size: 25px;line-height: 1.5;" v-show="formData.entifyname==null">
                请先配置设备识别相关参数<br>
              </p>

              <div>
                <el-form ref="elFormMg" :model="formDataMg"  size="medium" label-width="100px" v-show="formData.entifyname!=null">
                  <el-form-item label="第一行" prop="field101">
                    <el-input v-model="formDataMg.field101" clearable :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label="第二行" prop="field102">
                    <el-input v-model="formDataMg.field102" clearable :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label="第三行" prop="field103">
                    <el-input v-model="formDataMg.field103" clearable :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item label="第四行" prop="field104">
                    <el-input v-model="formDataMg.field104" clearable :style="{width: '100%'}"></el-input>
                  </el-form-item>
                  <el-form-item size="large">
                    <el-button type="primary" @click="submitFormMg">提交</el-button>
                    <el-button @click="resetFormMg">重置</el-button>
                  </el-form-item>
                </el-form>
              </div>

              <!--              -&#45;&#45;---------------------------------------------------------------------------------------------------------------------------->


              <!--              -&#45;&#45;---------------------------------------------------------------------------------------------------------------------------->


            </el-tab-pane>
          </el-tabs>

        </div>

        <div>


        </div>
      </div>
      <!--      </div>-->


    </el-tab-pane>
  </el-tabs>
</template>
<script>

import {listLane, getLane, delLane, addLane, updateLane} from "@/api/modules/sys-cars-home/lane/lane";
import {listHome} from "@/api/modules/sys-cars-home/home";
import {listProperty} from "@/api/modules/sys-property/property";
import path from "path";
import {listBooth, listBoothLane} from "@/api/modules/sys-cars-home/booth/booth";
import item from "@/layout/components/Sidebar/Item.vue";
import laneedit from "@/views/modules/sys-cars-home/lane/laneedit.vue";
import {addEntify, listEntify, updateEntify} from "@/api/modules/sys-cars-home/api/entify";
import {listBoards} from "@/api/modules/sys-cars-home/api/boards";
import {listCamera} from "@/api/modules/sys-cars-home/api/camera";
import {v4 as uuidv4} from "uuid";

export default {


  data() {
    return {
      // 车场管理表格数据
      carshomeList: [],
      carshomeList2: [],

      // 物业数据
      propertyList: [],
      //岗亭数据
      boothLaneList: [],
//单个车道数据
      laneListedit: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 车道配置表格数据
      laneList: [],

      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,


      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        code: null,
        status: null,
        deleted: null,
        chbid: null,
        lanecode: null,
        lanename: null,
        lanetype: null,
        toll: null,
        screen: null,
        cartype: null,
        begintime: null,
        endtime: null,

        chid: null,
        chname: null,

        pmid: null,
        propertyName: null,
        boothname: null
      },

      // 查询参数
      queryParams2: {
        pmid: null,
      },
      // 查询参数
      queryParams3: {
        lanename: null,

      },

      editList: {
        chid: 2
      },
      // 表单参数
      form: {},

      activeName: 'first',


//设备配置
      //通道信息
      data: [],
      defaultProps: {
        children: 'children',
        label: 'label'
      },

      //页面渲染
      infobooth: true,
      infolane: false,

      laneform: {
        chname: '',
        boothname: undefined,
        chlid: undefined,
        lanename: undefined,
        lanetype: undefined,
      },

      lanetypeOptions: [{
        "label": "入口",
        "value": 0
      }, {
        "label": "出口",
        "value": 1
      }],


//车牌识别

      formData: {
        chlid: undefined,
        entifyname: null,
        entifyip: undefined,
        eqnumber: undefined,
        correlation: undefined,
        mors: 0,
        oorg: 0,
        log: 0,
        venue: 0,
        ipaddr: undefined,
        cameraid: null,
        boardsid: null,
        agreement: null,
        video: 0,
        screentype: undefined,
        volume: 5,
        remark: undefined,
        boardsname: undefined,
        cameraname: undefined,
        status: 0,
        entifyid: undefined,

        appip: undefined,
        adedit: undefined,
        ad: null,
      },
      rules: {
        entifyname: [{
          required: true,
          message: '请输入设备名称',
          trigger: 'blur'
        }],
        eqnumber: [{
          required: true,
          message: '请输入设备编号',
          trigger: 'blur'
        }],
        correlation: [{
          required: true,
          message: '请输入关联码',
          trigger: 'blur'
        }],
        mors: [{
          required: true,
          message: '请选择主副相机',
          trigger: 'change'
        }],
        oorg: [{
          required: true,
          message: '请选择异常开闸',
          trigger: 'change'
        }],
        status: [{
          required: true,
          message: '请选择是否启用',
          trigger: 'change'
        }],
        log: [{
          required: true,
          message: '请选择是否开启设备日志',
          trigger: 'change'
        }],
        venue: [{
          required: true,
          message: '请选择所在场地',
          trigger: 'change'
        }],
        ipaddr: [{
          required: true,
          message: '请输入设备IP',
          trigger: 'blur'
        }],
        // cameraid: [{
        //   required: true,
        //   message: '请选择相机品牌',
        //   trigger: 'change'
        // }],
        // boardsid: [{
        //   required: true,
        //   message: '请选择板卡名称',
        //   trigger: 'change'
        // }],
        // agreement: [{
        //   required: true,
        //   message: '请选择相机协议',
        //   trigger: 'change'
        // }],
        video: [{
          required: true,
          message: '视频接入不能为空',
          trigger: 'change'
        }],
        volume: [{
          required: true,
          message: '请选择屏显类型',
          trigger: 'change'
        }],
        remark: [{
          required: true,
          message: '请输入备注',
          trigger: 'blur'
        }],
      },

      morsOptions: [{
        "label": "主相机",
        "value": 0
      }, {
        "label": "副相机",
        "value": 1
      }],
      oorgOptions: [{
        "label": "不开闸",
        "value": 0
      }, {
        "label": "开闸",
        "value": 1
      }],
      statusOptions: [{
        "label": "启用",
        "value": 0
      }, {
        "label": "禁用",
        "value": 1
      }],
      logOptions: [{
        "label": "不开启",
        "value": 0
      }, {
        "label": "开启",
        "value": 1
      }],
      venueOptions: [{
        "label": "外场",
        "value": 0
      }, {
        "label": "内场",
        "value": 1
      }],


      cameraidOptions: [],


      boardsidOptions: [],


      agreementOptions: [{
        "label": "HTTP",
        "value": 0
      }, {
        "label": "MQTT",
        "value": 1
      }],
      videoOptions: [{
        "label": "视频",
        "value": 0
      }, {
        "label": "图片",
        "value": 1
      }],
      screentypeOptions: [{
        "label": "四方屏",
        "value": 0
      }, {
        "label": "二行竖屏",
        "value": 1
      }],


      entifyList: [],

      entifyform: {
        chlid: null
      },
      message: null,
      lanename: "one",


      //ETC天线

      rulesETC: {
        appip: [{
          required: true,
          message: 'APPID',
          trigger: 'blur'
        }],
        chlid: [{
          required: true,
          message: '请输入ETC车道编号',
          trigger: 'blur'
        }],
      },

      //广告


      infoadin: false,

      formDataMg: {
        field101: undefined,
        field102: undefined,
        field103: undefined,
        field104: undefined,
      },
    };
  },

  created() {
    this.getListCars()
    this.getList();
    this.getListProperty()



  },
  methods: {

    handleClick(tab, event) {
      if(tab.name=="second"){
        this.getbooth()
      }
    },

    showType(row, column, cellValue, index,) {
      if (cellValue) {
        return "出口";
      }
      return "入口";
    },


    /** 查询车场管理列表 */
    getListCars() {
      this.queryParams2.pmid = this.queryParams.pmid
      listHome(this.queryParams2).then(response => {
        this.carshomeList = response.rows;
      });
      listHome(null).then(response => {
        this.carshomeList2 = response.rows;
      });
    },

    /** 查询物业列表 */
    getListProperty() {
      this.loading = true;
      listProperty(this.queryParams).then(response => {
        this.propertyList = response.rows;
        this.loading = false;
      });
    },
    //清除车场
    clearCarshomeList() {
      this.queryParams2.pmid = this.queryParams.pmid
      this.queryParams.chid = null
      this.getListCars()
    },


    /** 查询车道配置列表 */
    getList() {
      this.loading = true;
      listLane(this.queryParams).then(response => {
        this.laneList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },


    // 表单重置
    reset() {
      this.form = {
        chlid: null,
        code: null,
        status: null,
        deleted: null,
        createTime: null,
        updateTime: null,
        chbid: null,
        lanecode: null,
        lanename: null,
        lanetype: null,
        toll: null,
        screen: null,
        cartype: null,
        begintime: null,
        endtime: null
      };
      this.resetForm("form");
    },


    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },


    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.chlid)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.$router.push("laneedit")
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const chlid = row.chlid || this.ids
      this.$router.push({
        path: 'laneedit',
        query: {
          chlid: chlid,
          operate: "修改",
        }
      });
    },
    /** 查看按钮操作 */
    handleLook(row) {
      this.reset();
      const chlid = row.chlid || this.ids
      this.$router.push({
        path: 'laneedit',
        query: {
          chlid: chlid,
          operate: "查看",
        }
      });
    },




    /** 删除按钮操作 */
    handleDelete(row) {
      const chlids = row.chlid || this.ids;
      this.$modal.confirm('是否确认删除车道配置编号为"' + chlids + '"的数据项？').then(function () {
        return delLane(chlids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sys-cars-home/lane/export', {
        ...this.queryParams
      }, `lane_${new Date().getTime()}.xlsx`)
    },


    /** 配置按钮操作 */
    handleEdit(row) {
      this.reset();
      const chlid = row.chlid || this.ids
      this.activeName = "second"
      this.editList.chid = row.carsHome.chid || this.ids
      this.getbooth()
    },

    //第二页

    getListLanes() {
      this.getbooth()
    },


    shuaxin() {
      this.getbooth()
      this.handleNodeClick
    },


    //渲染左边树形控件
    getbooth() {
      listBoothLane(this.editList.chid).then(res => {
        this.boothLaneList = res.rows

        //搞蒙了都
        let newaddr = this.boothLaneList.map(item => ({
          label: item.boothname,
          children: [
            ...(item.carsHomeLaneList.map(it => ({label: it.lanename})))
          ]
        }));
        this.data = newaddr
      })
    },

    async getLane() {
      await listLane(this.queryParams3).then(res => {
        this.laneListedit = res.rows

      })
    },


// 监听点击岗亭
   async handleNodeClick(data) {


      //点击子节点
      if (data.children == null) {

        //清空表单
        await this.resetFormentify()

        this.queryParams3.lanename = data.label
        await this.getLane();

        this.infobooth = false
        this.infolane = true

        //延时加载
        this.loading = true
        // setTimeout(() => {
          // 渲染数据
          this.laneform.chname = this.laneListedit[0].carsHome.chname
          this.laneform.boothname = this.laneListedit[0].carsHomeBooth.boothname
          this.laneform.chlid = this.laneListedit[0].chlid
          this.laneform.lanename = this.laneListedit[0].lanename
          this.laneform.lanetype = this.laneListedit[0].lanetype
          //天线
          this.entifyform.chlid = this.laneListedit[0].chlid
          //广告


         await this.getentifyList()
        // }, 1000)

        this.loading = false
        await this.getBoardsList()
        await this.getCameraList()


      } else if (data.children != null) {

        this.infobooth = true
        this.infolane = false

      }

    },


    //车场监控信息-------------------------------------------------------------------------

    //查到了按钮改为修改
    getentifyList() {
      listEntify(this.entifyform).then(response => {

        if (response.rows.length != 0) {
          this.message = "修改"
          this.formData = response.rows[0]
          this.formDataMg.field101=null
          this.formDataMg.field102=null
          this.formDataMg.field103=null
          this.formDataMg.field104=null
          if(this.formData.ad!=null){
            this.formDataMg.field101=this.formData.ad.split(",")[0];
            this.formDataMg.field102=this.formData.ad.split(",")[1];
            this.formDataMg.field103=this.formData.ad.split(",")[2];
            this.formDataMg.field104=this.formData.ad.split(",")[3];
          }else {

          }

        } else {
          this.message = "新增"
        }




      })
    },
    getCorrelation(){

      this.formData.correlation = uuidv4();
    },


    //渲染相机品牌 板卡类型
    getBoardsList() {
      listBoards(null).then(response => {
        this.boardsidOptions = response.rows
      })
    },
    getCameraList() {
      listCamera(null).then(response => {
        this.cameraidOptions = response.rows
      })
    },


    //添加修改监控
    toentify() {

      if (this.message === "新增") {
        this.formData.chlid = this.entifyform.chlid


        addEntify(this.formData).then(res => {
          if (res.code == 200) {
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
          }
        })
      } else if (this.message == "修改") {
        updateEntify(this.formData).then(res => {
          if (res.code == 200) {
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getentifyList()
          }
        })
      }


    },
    resetFormentify() {
      this.formData = {
        chlid: undefined,
        entifyname: undefined,
        entifyip: undefined,
        eqnumber: undefined,
        correlation: undefined,
        mors: 0,
        oorg: 0,
        log: 0,
        venue: 0,
        ipaddr: undefined,
        cameraid: null,
        boardsid: null,
        agreement: null,
        video: 0,
        screentype: undefined,
        volume: 5,
        remark: undefined,
        boardsname: undefined,
        cameraname: undefined,
        status: 0,
        entifyid: undefined,
        appip: undefined,
        adedit: undefined,
        ad: undefined,
      }
    },


    //ETC
    submitFormETC() {
      this.$refs['elFormETC'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetFormETC() {
      this.formData.appip = null;
    },

    submitFormMg() {
      this.$refs['elFormMg'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
        this.formData.ad=this.formDataMg.field101+","+this.formDataMg.field102+","+this.formDataMg.field103+","+this.formDataMg.field104
        updateEntify(this.formData).then(res => {
          if (res.code == 200) {
            this.$message({
              type: 'success',
              message: '保存成功!'
            });
            this.getentifyList()
          }
        })
      })
    },
    resetFormMg() {
      this.$refs['elFormMg'].resetFields()
    },


  }
};
</script>
<style lang="scss" scoped>
.box-contrain {
  width: 100%;
  height: 700px;
  //border: #00afff solid 1px;
  display: flex;
  justify-content: space-around;
}


</style>
